﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Style TargetType="{x:Type ToggleButton}">
        <Setter Property="Background" Value="{DynamicResource ToggleButtonBackgroundThemeBrush}" />
        <Setter Property="Foreground" Value="{DynamicResource ToggleButtonForegroundThemeBrush}" />
        <Setter Property="BorderBrush" Value="{DynamicResource ToggleButtonBorderThemeBrush}" />
        <Setter Property="BorderThickness" Value="{DynamicResource ToggleButtonBorderThemeThickness}" />
        <Setter Property="Padding" Value="12,4,12,5" />
        <Setter Property="HorizontalAlignment" Value="Center" />
        <Setter Property="VerticalAlignment" Value="Center" />
        <Setter Property="FontFamily" Value="{DynamicResource ContentControlThemeFontFamily}" />
        <Setter Property="FontWeight" Value="SemiBold" />
        <Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Grid>
                        <Border x:Name="Border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Margin="3">
                            <ContentControl x:Name="ContentPresenter" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" Margin="{TemplateBinding Padding}"
                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                        </Border>
                        <Rectangle x:Name="FocusVisualWhite" IsHitTestVisible="False" Stroke="{DynamicResource FocusVisualWhiteStrokeThemeBrush}" StrokeEndLineCap="Square" StrokeDashArray="1,1" Opacity="0" StrokeDashOffset="1.5" />
                        <Rectangle x:Name="FocusVisualBlack" IsHitTestVisible="False" Stroke="{DynamicResource FocusVisualBlackStrokeThemeBrush}" StrokeEndLineCap="Square" StrokeDashArray="1,1" Opacity="0" StrokeDashOffset="0.5" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="Border" Property="Background" Value="{DynamicResource ToggleButtonPointerOverBackgroundThemeBrush}" />
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter TargetName="Border" Property="Background" Value="{DynamicResource ToggleButtonPressedBackgroundThemeBrush}" />
                            <Setter TargetName="ContentPresenter" Property="Foreground" Value="{DynamicResource ToggleButtonPressedForegroundThemeBrush}" />
                        </Trigger>
                        <Trigger Property="IsChecked" Value="True">
                            <Setter TargetName="Border" Property="Background" Value="{DynamicResource ToggleButtonCheckedBackgroundThemeBrush}" />
                            <Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource ToggleButtonCheckedBorderThemeBrush}" />
                            <Setter TargetName="ContentPresenter" Property="Foreground" Value="{DynamicResource ToggleButtonCheckedForegroundThemeBrush}" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource ToggleButtonDisabledBorderThemeBrush}" />
                            <Setter TargetName="ContentPresenter" Property="Foreground" Value="{DynamicResource ToggleButtonDisabledForegroundThemeBrush}" />
                        </Trigger>

                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="True" />
                                <Condition Property="IsChecked" Value="True" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="Border" Property="Background" Value="{DynamicResource ToggleButtonCheckedPointerOverBackgroundThemeBrush}" />
                            <Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource ToggleButtonCheckedPointerOverBorderThemeBrush}" />
                            <Setter TargetName="ContentPresenter" Property="Foreground" Value="{DynamicResource ToggleButtonCheckedForegroundThemeBrush}" />
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsPressed" Value="True" />
                                <Condition Property="IsChecked" Value="True" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="Border" Property="Background" Value="{DynamicResource ToggleButtonCheckedPressedBackgroundThemeBrush}" />
                            <Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource ToggleButtonCheckedPressedBorderThemeBrush}" />
                            <Setter TargetName="ContentPresenter" Property="Foreground" Value="{DynamicResource ToggleButtonCheckedPressedForegroundThemeBrush}" />
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsEnabled" Value="False" />
                                <Condition Property="IsChecked" Value="True" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="Border" Property="Background" Value="{DynamicResource ToggleButtonCheckedDisabledBackgroundThemeBrush}" />
                            <Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource ToggleButtonDisabledBorderThemeBrush}" />
                            <Setter TargetName="ContentPresenter" Property="Foreground" Value="{DynamicResource ToggleButtonCheckedDisabledForegroundThemeBrush}" />
                        </MultiTrigger>
                        <Trigger Property="Validation.HasError" Value="True">
                            <Setter TargetName="FocusVisualWhite" Property="Opacity" Value="1" />
                            <Setter TargetName="FocusVisualBlack" Property="Opacity" Value="1" />
                            <Setter TargetName="FocusVisualWhite" Property="Stroke" Value="{DynamicResource ControlValidationInvalidThemeBrush}" />
                            <Setter TargetName="FocusVisualBlack" Property="Stroke" Value="{DynamicResource ControlValidationInvalidThemeBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>